x86: improvements to pv_cpuid()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 15 Feb 2016 13:12:06 +0000 (14:12 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 15 Feb 2016 13:12:06 +0000 (14:12 +0100)
commit0359b365c6aaf1303244b064acc84c493cc0e730
treeafb89fe1e9dcf0d02310dc9ea504ae1a741023e5
parentbcfaea685d38c08e5eb90797512ab80f0bc69d0c
x86: improvements to pv_cpuid()

pv_cpuid() has two completely separate paths inside it depending on whether
current is dom0 or a domU.  This causes unnecessary divergence, and
complicates future improvements.  Take steps to undo it.

Changes:
 * Create leaf and subleaf variables and use them consistently, instead of a
   mix of {a,c} and regs->e{a,c}x as the input parameters.
 * Combine the dom0 and domU hypervisor leaf handling, with an early exit.
 * Apply sanity checks to domU as well.  This brings PV domU cpuid handling in
   line with HVM domains and PV dom0.
 * Perform a real cpuid instruction for calculating CPUID.0xD[ECX=0].EBX.  The
   correct xcr0 is in context, and this avoids the O(M*N) loop over the domain
   cpuid policy list which exists currently.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/traps.c